<template>
  <page-header-wrapper :title="false">
    <a-card>
      <div class="table-page-search-wrapper">
        <a-form layout="inline">
          <a-row :gutter="48">
            <a-col :md="6" :sm="8">
              <a-form-item label="筛选">
                <a-input v-model="queryParam.keyword" placeholder="请输入"/>
              </a-form-item>
            </a-col>
            <a-col :md="!advanced && 8 || 24" :sm="24">
              <span class="table-page-search-submitButtons" :style="advanced && { float: 'right', overflow: 'hidden' } || {} ">
                <a-button type="primary" @click="handleSearch">查询</a-button>
                <a-button style="margin-left: 8px" @click="() => queryParam = {}">重置</a-button>
                <!-- <a @click="toggleAdvanced" style="margin-left: 8px">
                  {{ advanced ? '收起' : '展开' }}
                  <a-icon :type="advanced ? 'up' : 'down'"/>
                </a> -->
              </span>
            </a-col>
          </a-row>
        </a-form>
      </div>

      <div class="table-operator">
        <a-button icon="cloud-upload">导出</a-button>
      </div>

      <a-table ref="table" size="default" rowKey="key" :columns="columns" :data-source="loadData">
        <span slot="serial" slot-scope="text, record, index">
          {{ index + 1 }}
        </span>
        <span slot="action" slot-scope="text, record">
          <template>
            <a-tag color="#428bca" @click="handleEdit(record)">编辑</a-tag>
            <a-tag color="red" @click="handleDelete(record)">删除</a-tag>
          </template>
        </span>
      </a-table>
    </a-card>
    <edit-form
      ref="editModal"
      :visible="editVisible"
      :loading="editLoading"
      :model="editMdll"
      @cancel="handleEditCancel"
      @ok="handleEditOk"
    />
  </page-header-wrapper>
</template>

<script>
import EditForm from './EditForm'
import { getServiceList } from '@/api/manage'
export default {
  name: 'ProtectPriceRecordEdit',
  components:{
    EditForm
  },
  data() {
    return {
      queryParam: {},
      advanced: false,
      priceMdll: null,
      editMdll: null,
      priceVisible: false,
      editVisible: false,
      priceLoading: false,
      editLoading: false,
      columns: [
        {
          title: '名称',
          dataIndex: '3',
        },
        {
          title: '串码',
          dataIndex: '4',
        },
        {
          title: '调整金额(元)',
          dataIndex: '5',
        },
        {
          title: '操作',
          dataIndex: 'action',
          width: '150px',
          scopedSlots: { customRender: 'action' },
        },
      ],
      loadData: [],
    }
  },
  methods: {
    handleSearch () {
      getServiceList().then(() => {
        this.loadData = [{ id: 1 }]
      })
      .catch(() => {
        this.loadData = [{ id: 1 }]
      })
    },
    handleEdit() {
      this.editMdll = { id: 1 }
      this.editVisible = true
    },
    handleEditOk() {
      this.editVisible = false
      this.editLoading = true
      setTimeout(() => {
        this.editLoading = false
      }, 1000)
      this.$message.success('操作成功')
    },
    handleEditCancel() {
      this.editVisible = false
      const form = this.$refs.editModal.form
      form.resetFields() // 清理表单数据（可不做）
    },
    handleDelete () {
    },
  },
}
</script>
